#!/bin/bash
# Author: yanjingtu <yanjingtu2008@yeah.net>
# Date: 2020/7/24
# Url: https://gitee.com/yanjingtu/centos-dockerfiles/tree/master/scripts/

# prepare for epel
./install-epel.sh

# install python2 & python3
yum install -q -y --nogpgcheck python2 python-pip python36 python36-setuptools
if ! [ -f /usr/bin/python3 ]; then
	ln -s python36 /usr/bin/python3
fi

echo "Before install pip"
ls -l /usr/bin/pip*

# install pip-sources for python3
#pip_ver=20.1.1
#curl https://mirrors.ustc.edu.cn/pypi/web/packages/c4/44/e6b8056b6c8f2bfd1445cc9990f478930d8e3459e9dbf5b8e2d2922d64d3/pip-9.0.3.tar.gz#md5=b15b33f9aad61f88d0f8c866d16c55d8 | tar -C / -zx
#curl https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/08/25/f204a6138dade2f6757b4ae99bc3994aac28a5602c97ddb2a35e0e22fbc4/pip-$pip_ver.tar.gz#sha256=27f8dc29387dd83249e06e681ce087e6061826582198a425085e0bf4c1cf3a55 | tar -C /tmp -zx
#if [ $? -ne 0 ]; then
#	echo "下载pip源码包失败，安装终止！"
#	exit 1
#fi
#cd /tmp/pip-$pip_ver
#python36 setup.py build > /dev/null
#python36 setup.py install > /dev/null
#rm -f /pip-9.0.3.tar.gz
#rm -rf /tmp/pip-$pip_ver
#echo "After install pip"
#ls -l /usr/bin/pip*
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple pip -U

# set pypi proxy & upgrade pip
#echo '[global]' > /etc/pip.conf
#echo 'index-url = https://mirrors.ustc.edu.cn/pypi/web/simple' >> /etc/pip.conf
#echo 'format = columns' >> /etc/pip.conf
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pip -U
